package edu.bit.water.controller;

import edu.bit.water.entity.MetaStandardRequire;
import edu.bit.water.service.MetaStandardRequireService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/require")
public class MetaStandardRequireController {

    protected static final Logger logger = LoggerFactory.getLogger(MetaEvaWuseInfoController.class);

    @Autowired
    private MetaStandardRequireService metaStandardRequireService;

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object> queryStandard(MetaStandardRequire metaStandardRequire) {
        metaStandardRequire.showContent();
        Map<String, Object> result = new HashMap<>();
        List<MetaStandardRequire> list = metaStandardRequireService.queryStandardRequire(metaStandardRequire);
        for(int i=0;i<list.size();i++) {
            MetaStandardRequire metaStandardRequire1 = list.get(i);
            logger.info("controller:"+metaStandardRequire1.getContent());
        }
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertMetaStandardRequire(MetaStandardRequire metaStandardRequire) {
        metaStandardRequire.showContent();
        Map<String, Object> result = metaStandardRequireService.insertMetaStandardRequireService(metaStandardRequire);
        return result;
    }

    /**
     * 删除metaStandardRequire
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteMetaStandardRequire(@RequestBody List<String>metaStandardRequires) {
        return metaStandardRequireService.deleteMetaStandardRequires(metaStandardRequires);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaStandardRequire(MetaStandardRequire metaStandardRequire) {
        metaStandardRequire.showContent();
        Map<String, Object> result = metaStandardRequireService.updateMetaStandardRequireService(metaStandardRequire);
        return result;
    }
}
